package com.xbongbong.saas.model.impl;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.DateUtil;
import com.xbongbong.saas.domain.dao.CouponDao;
import com.xbongbong.saas.domain.entity.CouponEntity;
import com.xbongbong.saas.model.CouponModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

;

/**
 * @author bomfish
 */
@Service("couponModel")
public class CouponModelImpl implements CouponModel {
    @Resource
    private CouponDao couponDao;

    @Override
    public Long insert(CouponEntity entity) {
        long now = DateUtil.getInt();
        entity.setDel(0);
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return couponDao.insert(entity);
    }

    @Override
    public void insertBatch(List<CouponEntity> list) {
        couponDao.insertBatch(list);
    }

    @Override
    public List<CouponEntity> findEntities(Map<String, Object> param) {
        return couponDao.findEntities(param);
    }

    @Override
    public Integer getEntityCount(Map<String, Object> param) {
        return couponDao.getEntitiesCount(param);
    }

    @Override
    public void update(CouponEntity entity) {
        couponDao.update(entity);
    }

    @Override
    public CouponEntity getByKey(Long key, String corpid) {
        return couponDao.getByKey(key, corpid);
    }

    @Override
    public Integer updateBatch(List<CouponEntity> updateList, String corpid) throws XbbException {
        return couponDao.updateBatch(updateList, corpid);
    }

    @Override
    public List<CouponEntity> findEntitysByIdIn(List<Long> couponIdList, String corpid) {
        return couponDao.findEntitysByIdIn(couponIdList, corpid);
    }

}
